var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        });
Object.defineProperty(o, "__esModule", {value: !0});
var n = t("BaseManager"),
    r = t("GameEm"),
    s = (function (t) {
        i(e, t);
        function e(e, o) {
            void 0 === o && (o = !1);
            var a = t.call(this, e, o) || this;
            a.curVersion = "";
            a.curSelLevel = 0;
            a.maxLv = 0;
            a.curSelCardBg = 0;
            a.curSelCardFront = 0;
            a.propData = {};
            a.orders = [];
            a.timeData = {};
            a.verData = 1;
            a.signAdIsView = {};
            a.lvStar = {};
            a.levelPage = 0;
            a.first = !0;
            a.dayString = "";
            a.lastIdCard = "";
            a.selfEquip = {};
            a.allEquip = 0;
            a.curWear = {};
            a.rewardList = [];
            a.saveLevelData = null;
            a.shopObjTime = {};
            a.dayShopItemIsBuy = {};
            a.canOpenNewTip = !1;
            a.haveNewEquip = !1;
            a.haveCanWearRed = !1;
            a.qualityData = {};
            a.allKeyCount = {};
            a.buySkillLv = {};
            a.buySkillUnLock = -1;
            a.isVib = !0;
            a.hotFoodData = null;
            a.lastHotClickTime = 0;
            a.invateData = null;
            a.invateCdTime = 0;
            a.lastViewInvate = null;
            a.isInvateNewDay = !0;
            a.isFirstOpenPay = !1;
            a.map1 = !1;
            a.isTipZsDlg = !0;
            if (o) {
                a.loadData();
                a.init();
            }
            return a;
        }
        e.prototype.init = function () {};
        return e;
    })(n.ArchiveBase),
    c = new ((function () {
        function t() {
            this.saveKey = "mmGameDataValueSave";
            this.parseObj = {};
            this.psw = {
                aa: "curVersion",
                ab: "curSelLevel",
                ac: "propData",
                ad: "timeData",
                ae: "signAdIsView",
                af: "selfEquip",
                ag: "allEquip",
                ah: "curWear",
                ai: "rewardList",
                aj: "shopObjTime",
                ak: "canOpenNewTip",
                al: "haveNewEquip",
                am: "qualityData",
                an: "allKeyCount",
                ao: "buySkillLv",
                ap: "buySkillUnLock",
                aq: "dayShopItemIsBuy",
                ar: "orders",
                as: "dayString"
            };
            this.curDate = null;
            this.maxStarCountAdd = 4;
        }
        t.prototype.initAccount = function (t) {
            var e = this.saveKey,
                o = cc.sys.localStorage.getItem(e);
            this.saveKey = "mmGameDataValueSave_" + t;
            if (o && "key not define" != o) {
                cc.sys.localStorage.setItem(this.saveKey, o);
                cc.sys.localStorage.setItem(e, "");
            }
            this._archive = new s(this.saveKey, !0);
            this.checkLoadData();
            this._archive.first && (this._archive.first = !1);
            if (o && "key not define" != o) {
                this._archive.saveLevelData = null;
                this._archive.saveData();
            }
            this.checkNewDay();
        };
        t.prototype.checkNewDay = function () {
            var t = this.getDate();
            if (this._archive.dayString != t) {
                this._archive.dayString = t;
                this._archive.lastViewInvate = null;
                this._archive.isInvateNewDay = !0;
                this._archive.isTipZsDlg = !0;
                this._archive.dayShopItemIsBuy = {};
                this._archive.saveData();
            }
        };
        t.prototype.isTipUseZs = function () {
            return this._archive.isTipZsDlg;
        };
        t.prototype.setTipUseZs = function (t) {
            this._archive.isTipZsDlg = t;
            this._archive.saveData();
        };
        t.prototype.isFirstOpenKey = function () {
            return this._archive.isFirstOpenPay;
        };
        t.prototype.setFirstOpenKey = function (t) {
            this._archive.isFirstOpenPay = t;
            this._archive.saveData();
        };
        t.prototype.isOpenShopItem = function (t, e) {
            return this._archive.dayShopItemIsBuy[t + "_" + e];
        };
        t.prototype.clearBuyShopItem = function () {
            this._archive.dayShopItemIsBuy = {};
            this._archive.saveData();
        };
        t.prototype.openShopItemData = function (t, e) {
            this._archive.dayShopItemIsBuy[t + "_" + e] = !0;
            this._archive.saveData();
        };
        t.prototype.setHaveCanWear = function (t) {
            this._archive.haveCanWearRed = t;
            this._archive.saveData();
            this.checkNewEquip();
        };
        t.prototype.checkLoadData = function () {
            var t = this;
            this._archive.map1 = !1;
            this._archive.map1 ||
                this.loadCallBack(function (e) {
                    t.parsePlayerData(e);
                    t._archive.saveData();
                });
        };
        t.prototype.loadCallBack = function (t) {
            var e = this;
            if (window.PlayerData && window.PlayerData.canLoadData) {
                window.PlayerData.checkOverCount++;
                t && t(PlayerData.getParseDataValueString());
            } else
                setTimeout(function () {
                    e.loadCallBack(t);
                }, 100);
        };
        t.prototype.getPlayerData = function () {
            var t = this._archive;
            for (var e in this.psw) {
                var o = this.psw[e];
                this.parseObj[e] = t[o];
            }
            return JSON.stringify(this.parseObj);
        };
        t.prototype.parsePlayerData = function (t) {
            if ("" != t) {
                var e = this._archive,
                    o = JSON.parse(t);
                for (var a in o) {
                    var i = this.psw[a];
                    i && o[a] && (e[i] = o[a]);
                }
            }
            this.checkNewDay();
        };
        t.prototype.resetData = function () {
            this._archive = new s(this.saveKey, !1);
            this._archive.saveData();
        };
        t.prototype.getBuyLockLv = function () {
            return this._archive.buySkillUnLock;
        };
        t.prototype.getNewInvate = function () {
            return this._archive.isInvateNewDay;
        };
        t.prototype.resetNewInvate = function () {
            this._archive.isInvateNewDay = !1;
            this._archive.saveData();
        };
        t.prototype.addBuyLockLv = function () {
            this._archive.buySkillUnLock++;
            this._archive.saveData();
        };
        t.prototype.getHotTime = function () {
            return this._archive.hotFoodData;
        };
        t.prototype.getLastHotTime = function () {
            return this._archive.lastHotClickTime;
        };
        t.prototype.setHotData = function (t) {
            if ("" == t) {
                this._archive.lastHotClickTime = Date.now();
                this.setNullHotData();
            } else this._archive.hotFoodData = {foodId: t, time: Date.now()};
            this._archive.saveData();
        };
        t.prototype.getVib = function () {
            return this._archive.isVib;
        };
        t.prototype.playVib = function () {
            this.getVib();
        };
        t.prototype.setVib = function (t) {
            this._archive.isVib = t;
            this._archive.saveData();
        };
        t.prototype.setNullHotData = function () {
            this._archive.hotFoodData = null;
            this._archive.saveData();
        };
        t.prototype.getLevelData = function () {
            if (this._archive.curVersion != GameCof.version) {
                this._archive.curVersion = GameCof.version;
                this._archive.saveData();
            }
            if (this._archive.saveLevelData && this._archive.saveLevelData.curLv == this._archive.curSelLevel)
                return this._archive.saveLevelData;
            this.setNullHotData();
            return null;
        };
        t.prototype.setQualityData = function (t, e) {
            var o = this._archive.qualityData[t] || 0;
            this._archive.qualityData[t] = Math.max(o, e);
            if (o != this._archive.qualityData[t]) {
                this._archive.haveNewEquip = !0;
                this.checkNewEquip();
            }
            this._archive.saveData();
        };
        t.prototype.closeAllEquip = function () {
            this._archive.haveNewEquip = !1;
            this.checkNewEquip();
            CacheDataManager.isUpdateRed = !0;
            this._archive.saveData();
        };
        t.prototype.checkNewEquip = function () {
            CacheDataManager.setRedData(r.RedEm.newEquip, this.canWearStatus() || CacheDataManager.canMerageData);
            CacheDataManager.isUpdateRed = !0;
        };
        t.prototype.canWearStatus = function () {
            return this._archive.haveNewEquip || this._archive.haveCanWearRed;
        };
        t.prototype.getQualityData = function (t) {
            return this._archive.qualityData[t] || 0;
        };
        t.prototype.setLevelData = function (t) {
            this._archive.saveLevelData = t;
            if (this._archive.saveLevelData) {
                this._archive.saveLevelData.curLv = this._archive.curSelLevel;
                this._archive.saveLevelData.saveTime = Date.now();
            }
            null == t && this.setNullHotData();
            this._archive.saveData();
        };
        t.prototype.setBuySkillLv = function (t, e) {
            this._archive.buySkillLv[t] = e;
            this._archive.saveData();
            CacheDataManager.updateDataSave();
        };
        t.prototype.clearBuySkill = function () {
            this._archive.buySkillLv = {};
            this._archive.saveData();
            CacheDataManager.updateDataSave();
        };
        t.prototype.getBuySkillLv = function (t) {
            return this._archive.buySkillLv[t] || 0;
        };
        t.prototype.getWearEquip = function (t) {
            return this._archive.curWear[t];
        };
        t.prototype.wearEquipId = function (t, e) {
            this._archive.curWear[e] = t;
            this._archive.saveData();
            CacheDataManager.updateCostDataView = !0;
            CacheDataManager.updateAllAddView();
            CacheDataManager.isUpdateWear = !0;
        };
        t.prototype.addEquip = function (t, e) {
            void 0 === e && (e = 1);
            QReport.send(t);
            this._archive.allEquip++;
            var o = {id: t, curExp: 0, indexId: this._archive.allEquip + "", lv: e};
            this._archive.selfEquip[this._archive.allEquip] = o;
            this._archive.saveData();
            CacheDataManager.updateCostDataView = !0;
            CacheDataManager.updateEquip = !0;
            CacheDataManager.updateDataSave();
        };
        t.prototype.upExpEquip = function (t) {
            if (this._archive.selfEquip && this._archive.selfEquip[t]) {
                this._archive.selfEquip[t].lv++;
                this._archive.saveData();
                CacheDataManager.updateAllAddView();
                this._archive.saveData();
                return !0;
            }
            return !1;
        };
        t.prototype.addRewardKind = function (t, e) {
            void 0 === e && (e = 1);
            var o = t + "";
            switch (o) {
                case "6":
                case "5":
                case "7":
                    console.log(
                        "GameDataValue --------宝箱数据--------- " +
                            t +
                            ": this.getShopKey(kindKey)" +
                            this.getShopKey(o) +
                            "+" +
                            e
                    );
                    this.setShopKey(o, this.getShopKey(o) + e);
            }
            this._archive.saveData();
        };
        t.prototype.haveNewTip = function () {
            return this._archive.canOpenNewTip;
        };
        t.prototype.openNewTip = function () {
            this._archive.canOpenNewTip = !0;
            this._archive.saveData();
        };
        t.prototype.closeNewTip = function () {
            this._archive.canOpenNewTip = !1;
            this._archive.saveData();
        };
        t.prototype.getRewardCount = function () {
            return this._archive.rewardList.length;
        };
        t.prototype.getOnceRewardKind = function () {
            if (this._archive.rewardList.length > 0) {
                var t = this._archive.rewardList.pop();
                this._archive.saveData();
                return t;
            }
            return null;
        };
        t.prototype.getLastRewardKind = function () {
            return this._archive.rewardList.length > 0
                ? this._archive.rewardList[this._archive.rewardList.length - 1]
                : null;
        };
        t.prototype.getAllSelfEquip = function () {
            return this._archive.selfEquip;
        };
        t.prototype.getEquipData = function (t) {
            return this._archive.selfEquip[t];
        };
        t.prototype.resetEquipLv = function (t) {
            if (this._archive.selfEquip[t]) {
                this._archive.selfEquip[t].lv = 1;
                CacheDataManager.updateEquip = !0;
            }
        };
        t.prototype.removeEquip = function (t) {
            var e = "";
            if (this._archive.selfEquip[t]) {
                e = this._archive.selfEquip[t].id;
                delete this._archive.selfEquip[t];
                for (var o in this._archive.curWear) this._archive.curWear[o] == t && (this._archive.curWear[o] = null);
                this._archive.saveData();
            }
            CacheDataManager.updateEquip = !0;
            return e;
        };
        t.prototype.newDay = function () {
            this._archive.dayString = "1";
            this._archive.saveData();
        };
        t.prototype.getDate = function () {
            this.curDate || (this.curDate = new Date(GameCof.serverTime));
            return this.curDate.getFullYear() + "-" + this.curDate.getMonth() + "-" + this.curDate.getDate();
        };
        t.prototype.getDay = function () {
            this.curDate || (this.curDate = new Date(GameCof.serverTime));
            return this.curDate.getMonth() + "" + this.curDate.getDate();
        };
        t.prototype.getPropCount = function (t) {
            return this._archive.propData[t] || 0;
        };
        t.prototype.setPropCount = function (t, e, o) {
            void 0 === o && (o = 0);
            this._archive.propData[t] = e;
            this._archive.saveData();
            CacheDataManager.updateCostDataView = !0;
            CacheDataManager.updateDataSave();
            PlayerData.getSaveData();
        };
        t.prototype.getPropOrder = function () {
            return this._archive.orders || [];
        };
        t.prototype.setPropOrder = function (t, e, o) {
            void 0 === o && (o = 0);
            this._archive.orders = e;
            this._archive.saveData();
            PlayerData.getSaveData();
        };
        t.prototype.getSignIsViewAd = function (t) {
            return this._archive.signAdIsView[t] || !1;
        };
        t.prototype.setSignViewAd = function (t, e) {
            this._archive.signAdIsView[t] = e;
            this._archive.saveData();
        };
        t.prototype.getLevelPage = function () {
            return this._archive.levelPage;
        };
        t.prototype.setLevelPage = function (t) {
            this._archive.levelPage = t;
            this._archive.saveData();
        };
        t.prototype.getLastLv = function () {
            return this._archive.curSelLevel;
        };
        t.prototype.setSelLv = function (t) {
            this._archive.curSelLevel = t;
            this._archive.saveLevelData = null;
            this.setNullHotData();
            t > this._archive.maxLv && (this._archive.maxLv = t);
            this._archive.saveData();
            PlayerData.getSaveData();
        };
        t.prototype.setMaxLv = function (t) {
            if (t > this._archive.maxLv) {
                this._archive.maxLv = t;
                this._archive.lvStar[t] = 1;
            }
            this._archive.saveData();
        };
        t.prototype.getMaxLevel = function () {
            return this._archive.maxLv;
        };
        t.prototype.getCardFrontIndex = function () {
            return this._archive.curSelCardFront;
        };
        t.prototype.setInvateData = function (t, e) {
            if (t) {
                if (!this._archive.invateData) {
                    this._archive.invateData = {data: t, time: e};
                    this._archive.lastViewInvate = null;
                }
            } else this._archive.invateData = null;
            this._archive.saveData();
        };
        t.prototype.updateInvateCdTime = function () {
            this._archive.invateCdTime = Date.now();
            this._archive.saveData();
        };
        t.prototype.addTempInvate = function (t) {
            this._archive.lastViewInvate = t;
            this._archive.saveData();
        };
        t.prototype.getTempInvate = function () {
            return this._archive.lastViewInvate;
        };
        t.prototype.getInvateCdTime = function () {
            return this._archive.invateCdTime;
        };
        t.prototype.resetInvateTime = function () {
            this._archive.invateCdTime = 0;
            this._archive.saveData();
        };
        t.prototype.getInvateData = function () {
            return this._archive.invateData;
        };
        t.prototype.getCardBgIndex = function () {
            return this._archive.curSelCardBg;
        };
        t.prototype.setCurStarCount = function (t, e) {
            if ((e += 1) > this.getStarCount(t) + 1) {
                this._archive.lvStar[t] = e;
                this._archive.lvStar[t] == this.maxStarCountAdd && delete this._archive.lvStar[t];
                this._archive.saveData();
            }
        };
        t.prototype.getStarCount = function (t) {
            var e = 1;
            t < this._archive.maxLv && (e = this._archive.lvStar[t] || this.maxStarCountAdd);
            return Math.max(0, e - 1);
        };
        t.prototype.getTimeCount = function (t) {
            return this._archive.timeData[t] || 0;
        };
        t.prototype.setTimeCount = function (t, e) {
            this._archive.timeData[t] = e;
            this._archive.saveData();
            PlayerData.getSaveData();
        };
        t.prototype.getShopTimeCount = function (t, e) {
            var o = t + "_" + e;
            return this._archive.shopObjTime[o] || 0;
        };
        t.prototype.setShopTimeCount = function (t, e, o) {
            var a = t + "_" + e;
            this._archive.shopObjTime[a] = o;
            this._archive.saveData();
            PlayerData.getSaveData();
        };
        t.prototype.getShopKey = function (t) {
            return this._archive.allKeyCount[t] || 0;
        };
        t.prototype.setShopKey = function (t, e) {
            this._archive.allKeyCount[t] = e;
            this._archive.saveData();
            PlayerData.getSaveData();
        };
        return t;
    })())();
window.GameDataValue = c;
o.default = c;
